package com.yy.studyspringboot.Interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

/**
 * 拦截配置类，配置静态资源以及拦截的请求
 */
@Configuration
public class Configurer implements WebMvcConfigurer {
    @Autowired
    private InterceptorTest interceptorTest;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptorTest)
                .addPathPatterns("/interceptors/*") //需要拦截的接口
                .excludePathPatterns("/interceptors/to_login", "/interceptors/do_login"); //排除不需要的接口
    }

    // 这个方法是用来配置静态资源的，比如html，js，css，等等
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
    }
}
